<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 认证类，加入一些权限认证等方法
 * @author Administrator
 *
 */
class Auth{
    var $user = null;
    //专营店常量
    var $roleSellpoint = 1;
    //小区督导端常量
    var $roleSpsarea = 2;
    //专员端常量
    var $roleSpecial = 3;
    //大区总监常量
    var $roleRegion = 4;
    //区域总监常量
    var $roleArea  = 5;
    //总部常量
    var $roleHead = 6;
    //查看角色常量
    var $roleCheck = 7;
    /**
     * 构造函数
     * @param array $user
     */
    function Auth($user){
        $this->user = $user;
    }
    /**
     * 查看专营店反馈
     * @param array $project
     */
    function checkStoreProList($project = array()){
        $checkReportRole = array($this->roleArea,$this->roleRegion,$this->roleSpsarea,$this->roleSpecial,$this->roleHead,$this->roleCheck);
        if (!in_array($this->user['userRole'], $checkReportRole)){
            return false;
        }
        if ($project['status'] == 0){
            return false;
        }
        return true;
    }
    /**
     * 查看报告
     * @param array $project
     */
    function checkStoreProReport($project = array()){
        $checkReportRole = array($this->roleArea,$this->roleRegion,$this->roleSpsarea,$this->roleSpecial,$this->roleHead,$this->roleCheck);
        if (!in_array($this->user['userRole'], $checkReportRole)){
            return false;
        }
        /*if ($project['proStatus'] != 2){
            return false;
        }*/
        return true;
    }
    /**
     * 修改截至提交时间
     * @param array $project
     * @return boolean
     */
    function checkProjectEditEndTime($project = array()){
        $checkReportRole = array($this->roleArea,$this->roleRegion,$this->roleSpsarea,$this->roleSpecial,$this->roleHead,$this->roleCheck);
        if (!in_array($this->user['userRole'], $checkReportRole)){
            return false;
        }
        if ($project['status'] == 0){
            return false;
        }
        return true;
    }
    /**
     * 立即发布
     * @param array $project
     */
    function checkProjectPublish($project = array()){
        if (!in_array($this->user['userRole'], array($this->roleHead))){
            return false;
        }
        if ($project['status'] == 1){
            return false;
        }
        return true;
    }
    /**
     * 是否能修改
     * @param array $project
     * @return boolean
     */
    function checkProjectEdit($project = array()){
        if (!in_array($this->user['userRole'], array($this->roleHead))){
            return false;
        }
        if ($project['status'] == 1){
            return false;
        }
        return true;
    }
    /**
     * 是否能删除
     * @param array $project
     * @return boolean
     */
    function checkProjectDel($project = array()){
        if (!in_array($this->user['userRole'], array($this->roleHead))){
            return false;
        }
        if ($project['status'] == 1){
            return false;
        }
        return true;
    }
    /**
     * 是否有专营店问卷审核权限
     * @param array $storeProData
     * @return boolean
     */
    function checkStoreProAudit($storeProData = array()) {
        if (!in_array($this->user['userRole'], array($this->roleHead))){
            return false;
        }
        /* if ($storeProData['auditRs'] != 0){
            return false;
        } */
        return true;
    }
    /**
     * 是否有导入权限
     */
    function isImport(){
        if (!in_array($this->user['userRole'], array($this->roleHead))){
            return false;
        }
        return true;
    }
}